package com.cn.bulu.TEST;

import org.junit.Test;

import com.alipay.api.AlipayApiException;
import com.alipay.api.AlipayClient;
import com.alipay.api.DefaultAlipayClient;
import com.alipay.api.domain.AlipayFundTransToaccountTransferModel;
import com.alipay.api.request.AlipayFundTransToaccountTransferRequest;
import com.alipay.api.response.AlipayFundTransToaccountTransferResponse;
import com.cn.bulu.utils.alipay.config.AlipayConfig;

public class TestWidthwal {
	
	@Test
	public  void test1(){
		// 实例化客户端
		AlipayClient alipayClient0 = new DefaultAlipayClient("https://openapi.alipay.com/gateway.do", AlipayConfig.app_id,
				AlipayConfig.app_private_key, "json", "utf-8", AlipayConfig.alipay_public_key, "RSA2");


		AlipayFundTransToaccountTransferRequest request = new AlipayFundTransToaccountTransferRequest();
		
		AlipayFundTransToaccountTransferModel model = new AlipayFundTransToaccountTransferModel();
	
	
		//商户转账唯一订单号
		model.setOutBizNo("gjfs9fuku300g0954gf86105");
		//收款方账户类型。
		model.setPayeeType("ALIPAY_LOGONID");
		//收款方账户。
		model.setPayeeAccount("15639296517");
		//转账金额
		model.setAmount("30");
		//付款方真实姓名
		model.setPayerShowName("郑州鹿客互联网科技有限公司");
		//收款方真实姓名（最长支持100个英文/50个汉字）。   
		model.setPayeeRealName("夏光辉");
		//转账备注
		model.setRemark("张松涛顾客这是我们本次为你的问题进行测试的转账");
		
		request.setBizModel(model);

		AlipayFundTransToaccountTransferResponse response = null;
		try {
			response = alipayClient0.execute(request);
			System.out.println(response.getBody());
			if(response.isSuccess()){
				System.err.println("转账成功，开始业务");
				System.err.println(response.getBody());
			}else{
				System.out.println("转账失败，返回代码为："+response.getCode());
				System.err.println(response.getBody());
			}
		} catch (AlipayApiException e) {
			e.printStackTrace();
		}
	}
		
		
	/*
	@Test
	public void test2() {
		AlipayClient alipayClient = new DefaultAlipayClient("https://openapi.alipay.com/gateway.do", AlipayConfig.app_id,
				AlipayConfig.app_private_key, "json", "utf-8", AlipayConfig.alipay_public_key, "RSA2");
		AlipayFundTransOrderQueryRequest request = new AlipayFundTransOrderQueryRequest();
		
		AlipayFundTransOrderQueryModel model  = new AlipayFundTransOrderQueryModel();
		
		model.setOrderId("");
		model.setOutBizNo("W171705251376233200779438671");
		
		
		request.setBizModel(model);
		AlipayFundTransOrderQueryResponse response = null;
		try {
			response = alipayClient.execute(request);
			if (response.isSuccess()) {
				System.out.println("调用成功");
				String body = response.getBody();
				JSONObject jsonObject = JSONObject.parseObject(body);
				System.err.println(jsonObject.get("alipay_fund_trans_order_query_response"));
			} else {
				System.out.println("调用失败");
				String body = response.getBody();
				JSONObject jsonObject = JSONObject.parseObject(body);
				System.err.println(jsonObject.get("alipay_fund_trans_order_query_response"));
			}
		} catch (AlipayApiException e) {
			e.printStackTrace();
		}
	}*/

}

